<template>
  <div>
    <br>
    <el-descriptions class="margin-top"  :column="3" :size="big" border>
      <template slot="extra">
      </template>
      <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-user-solid"></i>
        员工编号
      </template>
        <p>{{emp.id}}</p>
    </el-descriptions-item>

      <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-view"></i>
        密码
      </template>
        <p>{{emp.password}}</p>
    </el-descriptions-item>
      <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-document"></i>
        员工类型
      </template>
        <p>{{emp.employee_type}}</p>
    </el-descriptions-item>
      <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-user"></i>
        姓名
      </template>
        <p>{{emp.name}}</p>
    </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-mobile-phone"></i>
          手机号
        </template>
        <p>{{emp.phone}}</p>
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-location-outline"></i>
          出生地
        </template>
        <p>{{emp.birthplace}}</p>
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-location-outline"></i>
          户口所在地
        </template>
        <p>{{emp.registered_residence}}</p>
      </el-descriptions-item>



      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-female"></i>
          性别
        </template>
        <p>{{emp.sex}}</p>
      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-date"></i>
          出生日期
        </template>
        <p>{{emp.birthday}}</p>
      </el-descriptions-item> <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-postcard"></i>
        身份证号
      </template>
      <p>{{emp.id_card}}</p>
    </el-descriptions-item> <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-office-building"></i>
        政治面貌
      </template>
      <p>{{emp.political}}</p>
    </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-s-custom"></i>
         民族
        </template>
        <p>{{emp.nation}}</p>

      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-location-outline"></i>
          籍贯
        </template>
        <p>{{emp.native_place}}</p>

      </el-descriptions-item>
      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-s-promotion"></i>
          电子邮件
        </template>
        <p>{{emp.email}}</p>

      </el-descriptions-item> <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-s-custom"></i>
        身高
      </template>
      <p>{{emp.height}}</p>

    </el-descriptions-item> <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-edit"></i>
        血型
      </template>
      <p>{{emp.blood_type}}</p>

    </el-descriptions-item> <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-tickets"></i>
        婚姻状况
      </template>
      <p>{{emp.marital_status}}</p>

    </el-descriptions-item> <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-office-building"></i>
        部门编号
      </template>
      <p>{{emp.department_number}}</p>

    </el-descriptions-item> <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-office-building"></i>
        部门名称
      </template>
      <p>{{emp.department_name}}</p>

    </el-descriptions-item> <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-office-building"></i>
        岗位编号
      </template>
      <p>{{emp.post_number}}</p>

    </el-descriptions-item>
      <el-descriptions-item>
      <template slot="label">
        <i class="el-icon-office-building"></i>
        岗位名称
      </template>
      <p>{{emp.post_name}}</p>
    </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-date"></i>
          入职日期
        </template>
        <p>{{emp.entry_date}}</p>
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-edit"></i>
          用工形式
        </template>
        <p>{{emp.employment_form}}</p>
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-edit"></i>
          人员来源
        </template>
        <p>{{emp.personnel_source}}</p>
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-office-building"></i>
          最高学历
        </template>
        <p>{{emp.highest_education}}</p>
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-school"></i>
          毕业院校
        </template>
        <p>{{emp.graduation_school}}</p>
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-school"></i>
          所学专业
        </template>
        <p>{{emp.major_studied}}</p>
      </el-descriptions-item>

      <el-descriptions-item>
        <template slot="label">
          <i class="el-icon-date"></i>
          毕业日期
        </template>
        <p>{{emp.graduation_date}}</p>
      </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">
                <i class="el-icon-tickets"></i>
                备注
              </template>
              无
            </el-descriptions-item>
    </el-descriptions>

  </div>

</template>

<script>
import {Message} from "element-ui";

export default {
  name: "HrInfo",
  data() {
    return {
      emp: {
        id : "",
        password : "",
        employee_type : "",
        name : "",
        sex : "",
        birthday : "",
        id_card : "",
        political : "",
        nation : "",
        native_place : "",
        phone : "",
        email : "",
        height : null,
        blood_type :"",
        marital_status : "",
        birthplace : '',
        registered_residence : "",
        department_number : null,
        department_name : "",
        post_number : null,
        post_name : "",
        entry_date : "",
        employment_form : "",
        personnel_source : "",
        highest_education : "",
        graduation_school : "",
        major_studied : "",
        graduation_date : "",
        is_quit : "",
      },
      hr: null,
      hr2: null,
      dialogVisible: false,
      dialogTipVisible : false,
      btnDisabled : false,
      passwdDialogVisible: false,
      size : '',
      disabled : true,
      employee_types:['总裁', '主管', '员工'],
      post_names : {
        '开发部' : ['C++开发', 'Java开发', 'C#开发', 'Python开发', 'Go开发'],
        '运维部' : ['云运维', '服务器运维'],
        '测试部' : ['系统测试', 'Bug测试'],
        '设计部' : ['UI设计', '动画设计'],
        '策划部' : ['策划', '系统策划'],
      },
      post_type_options : [],
      employee_forms:['实习生', '正式职工'],
      department_names : ['开发部', '运维部', '测试部', '设计部', '策划部'],
      personnel_sources:['校招', '社招'],
      politicals: ['群众', '共青团员', '中共预备党员', '中共党员', '无党派人士', '其他'],
      nations: [
        '蒙古族', '藏族', '苗族', '壮族', '回族', '维吾尔族', '彝族', '布依族',
        '朝鲜族', '侗族', '白族', '哈尼族', '傣族', '傈僳族', '畲族', '拉祜族',
        '满族', '瑶族', '土家族', '哈萨克族', '黎族', '佤族', '高山族', '水族',
        '东乡族', '景颇族', '土族', '仫佬族', '布朗族', '毛南族', '锡伯族', '普米族',
        '纳西族', '柯尔克孜族', '达斡尔族', '羌族', '撒拉族', '仡佬族', '阿昌族', '塔吉克族',
        '怒族', '俄罗斯族', '德昂族', '裕固族', '塔塔尔族', '鄂伦春族', '门巴族', '基诺族',
        '乌孜别克族', '鄂温克族', '保安族', '京族', '独龙族', '赫哲族', '珞巴族', '汉族',
        '其他',
      ],
      blood_types:['A型', 'B型', 'AB型', 'O型', '其他'],
      highest_educations: ['小学', '初中', '中专/高中', '专科', '本科', '硕士', '博士', '其他'],
      rules: {
        id : [{required : true, message : '请输入编号', trigger : 'blur'}],
        password : [{required : true, message : '请输入密码', trigger : 'blur'}],
        employee_type : [{required : true, message : '请输入员工类型', trigger : 'blur'}],
        name: [{required : true, message : '请输入姓名', trigger : 'blur'}],
        sex: [{required : true, message : '请输入性别', trigger : 'blur'}],
        birthday: [{required : true, message : '请输入出生日期', trigger : 'blur'}],
        id_card: [{required : true, message : '请输入身份证号码', trigger : 'blur'}, {
          pattern : /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
          message : '身份证号码格式不正确',
          trigger : 'blur'
        }],
        political : [{required : true, message : '请输入政治面貌', trigger : 'blur'}],
        nation : [{required : true, message : '请输入民族', trigger : 'blur'}],
        native_place : [{required : true, message : '请输入籍贯', trigger : 'blur'}],
        phone : [{required : true, message : '请输入电话号码', trigger : 'blur'}],
        email : [{required : true, message : '请输入邮箱地址', trigger : 'blur'}, {
          type : 'email',
          message : '邮箱格式不正确',
          trigger : 'blur'
        }],
        height : [{required : true, message : '请输入身高', trigger : 'blur'}],
        blood_type : [{required : true, message : '请输入血型', trigger : 'blur'}],
        marital_status : [{required : true, message : '请输入婚姻状况', trigger : 'blur'}],
        birthplace : [{required : true, message : '请输入出生地', trigger : 'blur'}],
        registered_residence : [{required : true, message: '请输入户口所在地', trigger : 'blur'}],
        department_number : [{required : true, message : '请输入部门编号', trigger : 'blur'}],
        department_name : [{required : true, message : '请输入部门名称', trigger : 'blur'}],
        post_number : [{required : true, message : '请输入岗位编号', trigger : 'blur'}],
        post_name : [{required : true, message : '请输入岗位名称', trigger : 'blur'}],
        entry_date : [{required : true, message : '请输入入职日期', trigger : 'blur'}],
        employment_form : [{required : true, message : '请输入用工形式', trigger: 'blur'}],
        personnel_source : [{required : true, message : '请输入人员来源', trigger : 'blur'}],
        highest_education : [{required : true, message : '请输入最高学历', trigger : 'blur'}],
        graduation_school : [{required : true, message : '请输入毕业院校', trigger : 'blur'}],
        major_studied : [{required : true, message : '请输入所学专业', trigger : 'blur'}],
        graduation_date : [{required : true, message : '请输入毕业日期', trigger : 'blur'}],
        is_quit : [{required : true, message : '请输入是否离职', trigger : 'blur'}],

        nationId: [{required: true, message: '请输入您组', trigger: 'blur'}],
        jobLevelId: [{required: true, message: '请输入职称', trigger: 'blur'}],
        posId: [{required: true, message: '请输入职位', trigger: 'blur'}],
        // workState: [{required: true, message: '请输入工作状态', trigger: 'blur'}],
        // contractTerm: [{required: true, message: '请输入合同期限', trigger: 'blur'}],
        // conversionTime: [{required: true, message: '请输入转正日期', trigger: 'blur'}],
        // notworkDate: [{required: true, message: '请输入离职日期', trigger: 'blur'}],
        // beginContract: [{required: true, message: '请输入合同起始日期', trigger: 'blur'}],
        // endContract: [{required: true, message: '请输入合同结束日期', trigger: 'blur'}],
        // workAge: [{required: true, message: '请输入工龄', trigger: 'blur'}],
      }
    }
  },
  mounted() {
    this.initHr();
  },
  methods: {
    onSuccess() {
      this.initHr();
    },
    showUpdateHrInfoView() {
      this.dialogVisible = true;
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.emp.id = localStorage.getItem("id")
          this.$axios.post('/DirectorDepartment', this.emp).then(resp => {
            if (resp) {
              this.emp = resp.data;
            }
          })
          // this.putRequest("/hr/pass", this.ruleForm).then(resp => {
          //     if (resp) {
          //         this.getRequest("/logout");
          //         window.sessionStorage.removeItem("user")
          //         this.$store.commit('initRoutes', []);
          //         this.$router.replace("/");
          //     }
          // })
        } else {
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    showUpdatePasswdView() {
      this.passwdDialogVisible = true;
    },
    initHr() {
      console.log("我执行了inithr")
      this.emp.id = localStorage.getItem("id")
      this.$axios.post('/DirectorDepartment', this.emp).then(resp => {
        if (resp) {
          console.log("我是修改后的data")
          console.log(resp.data)
          this.emp = resp.data;
        }
      })
    },
    edit() {
      this.dialogTipVisible = false;
      this.btnDisabled=!this.btnDisabled;
      console.log("我执行了")
      this.$axios.post('/Edit', this.emp).then(resp => {
        if (resp) {
          Message.success({message : resp.data.msg});
        } else {
          Message.error({message : resp.data.msg});
        }
      })
      // this.initHr();
    },
    cancelEdit() {
      this.dialogTipVisible = false;
      this.btnDisabled = !this.btnDisabled;
    },
    changeEditSelect() {
      // 清空部门内容
      this.emp.post_name = ''

      // 遍历部门的下拉选项数组
      for (const k in this.department_names) {
        // 岗位名称 是否等于 部门名称的下拉选择数组中的某一项
        if (this.emp.department_name === this.department_names[k]) {
          this.post_type_options = this.post_names[this.emp.department_name]
        }
      }
      console.log("post_type_options = "+this.post_type_options);
    },
  }
}
</script>

<style scoped>

</style>
